home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / uwin / cassette / cassedoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-28  |  4.7 KB  |  142 lines

  1. // Copyright (c) 1994, William Wagner
  2. // All Rights reserved.
  3. //
  4. // This source is a portion of a shareware program.  It may be distributed
  5. // only in its entirety.  The copyright statements must be included with any 
  6. // reproduction of this source.
  7. // 
  8.  
  9. #ifndef __CASSEDOC_H__
  10. #define __CASSEDOC_H__
  11.  
  12. // cassedoc.h : interface of the CCassetteDoc class
  13. //
  14. // CCassetteDoc is the class that handles a cassette document.  This class
  15. // holds the data that represents a cassette label J-Card.
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18.  
  19. // Defined constants for Updates:
  20. // These constants are passed to the View classes in an OnUpdate method.
  21. // Each defines what has changed.
  22.  
  23. // 100 - series:  Data has changed.
  24. //The name of the constants should be clear.  The fields are 
  25. // side one album, side two album, side one artist, side two artist,
  26. // side one songs, side two songs, notes.
  27. #define ALBUM1_CHANGE        100
  28. #define ALBUM2_CHANGE        101
  29. #define ARTIST1_CHANGE        102
  30. #define ARTIST2_CHANGE        103
  31. #define SONGS1_CHANGE        104
  32. #define SONGS2_CHANGE        105
  33. #define NOTES_CHANGE        106
  34.  
  35. // 200 - series:  Font information changed.
  36. //The name should be clear.  The fields are album font,
  37. // artist font, songs font, notes font.
  38. #define FONT_ALBUM_CHANGE    200
  39. #define FONT_ARTIST_CHANGE    201
  40. #define FONT_SONGS_CHANGE    202
  41. #define FONT_NOTES_CHANGE    203
  42.  
  43. class CCassetteDoc : public CDocument
  44. {
  45. protected: // create from serialization only
  46.     CCassetteDoc();
  47.     DECLARE_DYNCREATE(CCassetteDoc)
  48.  
  49. //Attributes
  50. public:
  51.     //These are the data members for a document.
  52.     
  53.     // Document version.  This is used to tag files so that future
  54.     // versions of this program can read and translate old data files.
  55.     LONG    m_lVersion;
  56.     
  57.     //Data members for the class.  These strings represent the 
  58.     // data for the cassette label.  Some of the strings may get
  59.     // very large.  (The Songs* variables contain CR/LF pairs and 
  60.     // contain the entire set of songs.  The cs is my Hungarian
  61.     // prefix for a CString.
  62.     CString    m_csAlbum1;        //Album, side 1.
  63.     CString    m_csAlbum2;        //Album, side 2.
  64.     CString    m_csArtist1;    //Artist, side 1.
  65.     CString    m_csArtist2;    //Artist, side 2.
  66.     CString    m_csSongs1;        //Songs, side 1.
  67.     CString    m_csSongs2;        //Songs, side 2.
  68.     CString    m_csNotes;        //Notes along the bottom.
  69.  
  70.     // Logical fonts used in the casssette program.
  71.     // Logical fonts are used because I can serialize them.  That
  72.     // way, the font information stored is properly reloaded
  73.     // again.  I use lfont for the Hungarian prefix.
  74.     // Different fonts are used for songs, artist, album, and notes.
  75.     LOGFONT m_lfontSongs;
  76.     LOGFONT m_lfontArtist;
  77.     LOGFONT m_lfontAlbum;
  78.     LOGFONT m_lfontNotes;
  79.  
  80. //Operations
  81. public:
  82.     //This function changes one of the fonts in the document.  The WhichFont
  83.     // parameter matches one of the 200-series constants used in the OnUpdate
  84.     // method.  This gives the user the CommonFont dialog to change any of 
  85.     // the fonts desired.  The font change commands are handled here becauase
  86.     // that way, it doesn't matter which view is active, it just works.
  87.     void DoFontCommand (int WhichFont);
  88.     
  89. // Implementation
  90. private:
  91.     //Initialize a logical font.  This initializes a logical font
  92.     // to 8 pt. MS San Serif.
  93.     void InitFont (LOGFONT* Font);
  94.     
  95.     //utility functions to read and write documents:
  96.     void ReadDocument (CArchive& ar);
  97.     void WriteDocument (CArchive& ar);
  98.     void ReadFont (CArchive& ar, LOGFONT* font);
  99.     void WriteFont (CArchive& ar, LOGFONT* font);
  100.         
  101.     //Change a font.  This utility function loads the CommDlg
  102.     // font dialog, and lets the user change the font.  The return
  103.     // value is return from the font dialos's DoModal () member
  104.     // either IDOK, or IDCANCEL.
  105.     int  ChangeFont (LOGFONT* Font);
  106.     
  107. public:
  108.  
  109.     //Emtpy a document.  However, this does not re-initialize the
  110.     // font information.  I was sort of figuring that users would
  111.     // want the font information sticky.  So, they can set the
  112.     // fonts they want and then just tweak them.
  113.     void DeleteContents ();
  114.     
  115.     //Destructor.
  116.     ~CCassetteDoc();
  117.     
  118.     //Serialization handler.
  119.     void Serialize(CArchive& ar);    // overridden for document i/o
  120. #ifdef _DEBUG
  121.     void AssertValid() const;
  122.     void Dump(CDumpContext& dc) const;
  123. #endif
  124.  
  125. // Generated message map functions
  126. // The document class updates the Save command to only allow it 
  127. // on a changed document.  All font commands are handled by the
  128. // document class.
  129. protected:
  130.     //{{AFX_MSG(CCassetteDoc)
  131.     afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
  132.     afx_msg void OnFontsAlbum();
  133.     afx_msg void OnFontsArtist();
  134.     afx_msg void OnFontsNotes();
  135.     afx_msg void OnFontsSongs();
  136.     //}}AFX_MSG
  137.     DECLARE_MESSAGE_MAP()
  138. };
  139.  
  140. /////////////////////////////////////////////////////////////////////////////
  141. #endif
  142.